<template>
  <div class="img-box wx_video">
    <img class="img-inline" :src="obj.imgUrl">
    <template v-if="allowPlay">
      <el-button type="text" class="video-icon" @click="play()">
        <i class="el-icon-video-play"></i>
      </el-button>
    </template>
    <template v-else>
      <i class="el-icon-video-play video-icon"></i>
    </template>
  </div>
  
</template>

<script>
export default {
  props:{
    isMe:{
      type:Boolean,
      default:function(){
        return false;
      }
    },//本组件中无用,与其他组件保持格式相同用
    allowPlay:{
      type:Boolean,
      default:function(){
        return false;
      }
    },
    obj:{
      mediaId:String,//临时素材库Id
      title:String,//标题
      abstract:String,//摘要
      imgUrl:String,//缩略图URL
      fileUrl:String,//视频存储在七牛的URL
      eS_Company_Id:String,//素材上传到的企业微信Id
      addTime:String,//添加时间
      editTime:String,//修改时间
    }
  },
  data(){
    return {
      msgtype:'video',
    }
  },
  methods:{
    play:function(){
      if(!this.allowPlay){
        return
      }
      let videoUrl = this.obj.fileUrl
      this.$msgbox({
        message:`<div class="img-box"><video class="video-inline" src="${videoUrl}" autoplay controls></video></div>`,
        customClass:'winClass',
        dangerouslyUseHTMLString:true,
        distinguishCancelAndClose:true,
        showConfirmButton:false,
        center:true,
      });
    }
  },
  mounted(){
    // console.log(`视频组件收到的allowPlay值为${this.allowPlay}`)
  },
}
</script>

<style lang="less" scoped>
.wx_video{
  position: relative;
  display: inline-block;
  min-width:200px;
  max-width:260px;
  min-height:114px;
  background-color:#000;
}
.video-icon{
  position: absolute;
  top:0;bottom:0;left:0;right:0;
  font-size: 48px;;
  width:48px;height:48px;
  margin:auto;
  color:#fff;
}


</style>